<?php
/**
 * Created by PhpStorm.
 * User: caoguangyang
 * Date: 2023-06-17
 * Time: 20:53
 */

namespace App\Services\Goods;
use App\Models\Goods\Brand;
use App\Services\BaseServices;

class BrandServices extends BaseServices {

    /**
     * @param int $id
     * @return \App\Models\BaseModel|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
     */
    public function getBrand(int $id) {
        return Brand::query()->where("id", $id)->where("deleted", 0)->first();
    }


    public function getBrandList(int $page, int $limit, $sort, $order, $columns = ['*']) {
        $query = Brand::query()->where("deleted", 0);
        if (!empty($sort) && !empty($order)) {
            $query = $query->orderBy($sort, $order);
        }
        return $query->paginate($limit, $columns, 'page', $page);
    }
}